home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software 2000
/
Software 2000 Volume 1 (Disc 1 of 2).iso
/
education
/
e077.dms
/
e077.adf
/
ScienceDemos
/
J2000
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1991-07-12
|
9KB
|
328 lines
' Program "J2000"
' copyright (C) 1986 by David Eagle
' 7952 W. Quarto Dr., Littleton, CO 80123, (303) 972-4020
' released into the public domain on March 20, 1986
' conversion of stellar positions, proper motions, parallax and
' radial velocity from the standard epoch B1950 (FK4) to J2000 (FK5)
' reference: Astronomical Almanac, 1985, page X
OPTION BASE 1
DEFDBL a-z
DIM a1(3),a2(3),upv(3),uvv(3),r1(3),r2(6),r3(6),v2(3),m(6,6)
SCREEN 1,640,200,3,2
WINDOW 5,"Program J2000",(0,0)-(630,185),0,1
PALETTE 4,0,0.8,0.2:' green
PALETTE 5,1,1,0:' yellow
PALETTE 6,0.8,0,0.93:' purple
PALETTE 7,0.93,0.2,0:' red
pi=5.30795e-315
pidiv2=pi/2
deg.to.rad=pi/180
rad.to.deg=180/pi
xe=pi/12
xer=12/pi
a1(1)=-5.19985e-315
a1(2)=-5.18759e-315
a1(3)=-5.18149e-315
a2(1)=0.001244
a2(2)=-0.001579
a2(3)=-0.00066
' define elements of transformation matrix
m(1,1)=5.29981e-315
m(1,2)=-5.26578e-315
m(1,3)=-5.25963e-315
m(1,4)=5.20278e-315
m(1,5)=-5.16936e-315
m(1,6)=-5.16294e-315
m(2,1)=5.26578e-315
m(2,2)=5.29981e-315
m(2,3)=-5.22096e-315
m(2,4)=5.16936e-315
m(2,5)=5.20278e-315
m(2,6)=-5.12435e-315
m(3,1)=5.25963e-315
m(3,2)=-5.22095e-315
m(3,3)=5.29981e-315
m(3,4)=5.16294e-315
m(3,5)=-5.12434e-315
m(3,6)=5.20278e-315
m(4,1)=-0.000551
m(4,2)=-0.238565
m(4,3)=0.435739
m(4,4)=5.29981e-315
m(4,5)=-5.26578e-315
m(4,6)=-5.25963e-315
m(5,1)=0.238514
m(5,2)=-0.002667
m(5,3)=-0.008541
m(5,4)=5.26578e-315
m(5,5)=5.29981e-315
m(5,6)=-5.22097e-315
m(6,1)=-0.435623
m(6,2)=0.012254
m(6,3)=0.002117
m(6,4)=5.25963e-315
m(6,5)=-5.22095e-315
m(6,6)=5.29981e-315
' initialization
CLS
select%=1
CALL yesno.menu("Program introduction ?",intro%)
IF intro%=1 THEN CALL introduction
' main program loop
WHILE select%=1
CLS
COLOR 3,0
PRINT "Right ascension with respect to 1950"
PRINT "< hours (0-23), minutes (0-59), seconds (0-59) >"
INPUT ras.hr.1950,ras.min.1950,ras.sec.1950
PRINT
COLOR 4,0
PRINT "Declination with respect to 1950"
PRINT "< degrees (-90 to +90), minutes (0-59), seconds (0-59) >"
INPUT dec.deg.1950,dec.min.1950,dec.sec.1950
PRINT
COLOR 5,0
PRINT "Right ascension proper motion with respect to 1950"
PRINT "< arc seconds per tropical century >"
INPUT ras.pmotion.1950
PRINT
PRINT "Declination proper motion with respect to 1950"
PRINT "< arc seconds per tropical century >"
INPUT dec.pmotion.1950
PRINT
COLOR 6,0
PRINT "Parallax with respect to 1950 < arc seconds >"
INPUT parallax.1950
PRINT
COLOR 7,0
PRINT "Radial velocity with respect to 1950 < kilometers per second >"
INPUT radialv.1950
' convert 1950 right ascension and declination to radians
ras.1950=xe*(ras.hr.1950+ras.min.1950/60+ras.sec.1950/3600)
dec.1950=deg.to.rad*SGN(dec.deg.1950)*(ABS(dec.deg.1950)+(dec.min.1950*60+dec.sec.1950)/3600)
' calculate unit position vector
upv(1)=COS(ras.1950)*COS(dec.1950)
upv(2)=SIN(ras.1950)*COS(dec.1950)
upv(3)=SIN(dec.1950)
k1=21.095*radialv.1950*parallax.1950
' calculate unit velocity vector
uvv(1)=-ras.pmotion.1950*SIN(ras.1950)*COS(dec.1950)-m2(1)*COS(ras.1950)*SIN(dec.1950)+k1*upv(1)
uvv(2)=ras.pmotion.1950*COS(ras.1950)*COS(dec.1950)-m2(1)*SIN(ras.1950)*SIN(dec.1950)+k1*upv(2)
uvv(3)=dec.pmotion.1950*COS(dec.1950)+k1*upv(3)
' E-term constants
k2=a1(1)*upv(1)+a1(2)*upv(2)+a1(3)*upv(3)
k3=a2(1)*upv(1)+a2(2)*upv(2)+a2(3)*upv(3)
FOR i%=1 TO 3
r1(i%)=upv(i%)-a1(i%)+k2*upv(i%)
r2(i%)=r1(i%)
v2(i%)=uvv(i%)-a2(i%)+k3*upv(i%)
r2(i%+3)=v2(i%)
NEXT i%
' matrix multiplication
FOR i%=1 TO 6
a=0
FOR j%=1 TO 6
a=a+m(i%,j%)*r2(j%)
NEXT j%
r3(i%)=a
NEXT i%
rm.2000=SQR(r3(1)^2+r3(2)^2+r3(3)^2)
' compute declination wrt j2000
CALL arcsin(r3(3)/rm.2000,b)
CALL convert(b*rad.to.deg,dec.deg.2000,dec.min.2000,dec.sec.2000)
' compute right ascension wrt j2000
CALL atan3(r3(2),r3(1),c)
CALL convert(c*xer,ras.hr.2000,ras.min.2000,ras.sec.2000)
k4=r3(1)^2+r3(2)^2
' compute proper motions wrt j2000
ras.pmotion.2000=(r3(1)*r3(5)-r3(2)*r3(4))/k4
dec.pmotion.2000=(r3(6)*k4-r3(3)*(r3(1)*r3(4)+r3(2)*r3(5)))/(rm.2000^2*SQR(k4))
' compute parallax and radial velocity wrt j2000
IF parallax.1950=0 THEN radialv.2000=radialv.1950 :ELSE radialv.2000=(r3(1)*r3(4)+r3(2)*r3(5)+r3(3)*r3(6))/(21.095*parallax.1950*rm.2000)
parallax.2000=parallax.1950/rm.2000
CLS
CALL display.data
CALL yesno.menu("Another selection ?",select%)
WEND
WINDOW CLOSE 5
SCREEN CLOSE 1
END
SUB convert(deg,hr,min,sec) STATIC
' convert degrees to hms or dms subroutine
hr=FIX(deg)
c=ABS(hr-deg)*60
min=INT(c)
d=(c-min)*60
sec=INT(d+0.5)
END SUB
SUB display.data STATIC
' display data subroutine
SHARED ras.hr.1950,ras.min.1950,ras.sec.1950,dec.deg.1950,dec.min.1950,dec.sec.1950,ras.pmotion.1950,dec.pmotion.1950,parallax.1950,radialv.1950
SHARED ras.hr.2000,ras.min.2000,ras.sec.2000,dec.deg.2000,dec.min.2000,dec.sec.2000,ras.pmotion.2000,dec.pmotion.2000,parallax.2000,radialv.2000
WINDOW 4,"J2000 Data (press left mouse button to continue)",(0,0)-(630,185),0,1
CLS
PRINT
COLOR 1,0
PRINT TAB(25);"* 1950 <FK4> *"
a$=STR$(ras.hr.1950)+" hours"+STR$(ras.min.1950)+" minutes"+STR$(ras.sec.1950)+" seconds"
COLOR 2,0
PRINT TAB(5);"Right ascension";TAB(60-LEN(a$));a$
a$=STR$(dec.deg.1950)+" degrees"+STR$(dec.min.1950)+" minutes"+STR$(dec.sec.1950)+" seconds"
COLOR 3,0
PRINT TAB(5);"Declination";TAB(60-LEN(a$));a$
PRINT
COLOR 4,0
PRINT TAB(5);"Right ascension proper motion";
LOCATE ,48
PRINT USING "########.###";ras.pmotion.1950
COLOR 5,0
PRINT TAB(5);"Declination proper motion";
LOCATE ,48
PRINT USING "########.###";dec.pmotion.1950
PRINT
COLOR 6,0
PRINT TAB(5);"Parallax (arc seconds)";
LOCATE ,48
PRINT USING "########.###";parallax.1950
COLOR 7,0
PRINT TAB(5);"Radial velocity (kilometers per second)";
LOCATE ,48
PRINT USING "########.###";radialv.1950
PRINT
COLOR 1,0
PRINT TAB(25);"* 2000 <FK5> *"
a$=STR$(ras.hr.2000)+" hour"+STR$(ras.min.2000)+" minutes"+STR$(ras.sec.2000)+" seconds"
COLOR 2,0
PRINT TAB(5);"Right ascension";TAB(60-LEN(a$));a$
a$=STR$(dec.deg.2000)+" degrees"+STR$(dec.min.2000)+" minutes"+STR$(dec.sec.2000)+" seconds"
COLOR 3,0
PRINT TAB(5);"Declination";TAB(60-LEN(a$));a$
PRINT
COLOR 4,0
PRINT TAB(5);"Right ascension proper motion";
LOCATE ,48
PRINT USING "########.###";ras.pmotion.2000
COLOR 5,0
PRINT TAB(5);"Declination proper motion";
LOCATE ,48
PRINT USING "########.###";dec.pmotion.2000
PRINT
COLOR 6,0
PRINT TAB(5);"Parallax (arc seconds)";
LOCATE ,48
PRINT USING "########.###";parallax.2000
COLOR 7,0
PRINT TAB(5);"Radial velocity (kilometers per second)";
LOCATE ,48
PRINT USING "########.###";radialv.2000
WHILE MOUSE(0)=0:WEND
WHILE MOUSE(0)<>0:WEND
WINDOW CLOSE 4
END SUB
SUB atan3(sinangle,cosangle,angle) STATIC
' four quadrant inverse tangent subroutine
SHARED pidiv2
IF ABS(sinangle)=0 THEN
angle=(1-SGN(cosangle))*pidiv2
ELSE
angle=(2-SGN(sinangle))*pidiv2
END IF
IF ABS(cosangle)>0 THEN angle=angle+SGN(sinangle)*SGN(cosangle)*(ABS(ATN(sinangle/cosangle))-pidiv2)
END SUB
SUB arcsin(sinangle,angle) STATIC
' inverse sine subroutine
SHARED pidiv2
IF ABS(sinangle)>=1 THEN
angle=SGN(sinangle))*pidiv2
ELSE
angle=ATN(sinangle/SQR(1-sinangle^2))
END IF
END SUB
SUB yesno.menu(request$,response%) STATIC
' yes/no request subroutine
WINDOW 4,request$,(0,0)-(215,45),0,1
LOCATE 1,1:PRINT PTAB(25);"press left mouse"
LOCATE 2,1:PRINT PTAB(25);"button to select"
LINE (20,20)-(80,40),1,b
LINE (140,20)-(190,40),1,b
LOCATE 4,1:PRINT PTAB(35);"Yes";PTAB(155);"No";
response%=-1
WHILE response%=-1
WHILE MOUSE(0)=0:WEND
mx=MOUSE(1):my=MOUSE(2)
IF (mx>20 AND mx<80) AND (my>20 AND my<40) THEN
response%=1
WHILE MOUSE(0)<>0:WEND
END IF
IF (mx>140 AND mx<190) AND (my>20 AND my<40) THEN
response%=2
WHILE MOUSE(0)<>0:WEND
END IF
WEND
WINDOW CLOSE 4
END SUB
SUB introduction STATIC
' program introduction subroutine
CLS
PRINT
PRINT TAB(4);"J2000 is an interactive AmigaBasic program which can be"
PRINT TAB(4);"used to convert stellar positions, proper motions,"
PRINT TAB(4);"parallax and radial velocity from the standard epoch"
PRINT TAB(4);"B1950 (FK4) to J2000 (FK5). The method used in this"
PRINT TAB(4);"program is based on the algorithm published in the 1985"
PRINT TAB(4);"edition of the Astronomical Almanac, Addendum to Section"
PRINT TAB(4);"B, page X. This technique is an approximation because"
PRINT TAB(4);"it does not account for systematic and individual star"
PRINT TAB(4);"corrections between the FK4 and FK5 epochs."
PRINT
PRINT TAB(4);"J2000 will first request the right ascension, declination,"
PRINT TAB(4);"right ascension proper motion, declination proper motion,"
PRINT TAB(4);"parallax and radial velocity of a stellar object with"
PRINT TAB(4);"respect to the 1950 (FK4) epoch. Each program prompt will"
PRINT TAB(4);"advise you of the proper units to input. If you do not"
PRINT TAB(4);"have a number for proper motion or parallax or radial"
PRINT TAB(4);"velocity, then input '0' for any of these values."
CALL nextpage
END SUB
SUB nextpage STATIC
' select next page subroutine
PRINT
PRINT TAB(13);"< press left mouse button to continue >"
WHILE MOUSE(0)=0:WEND
WHILE MOUSE(0)<>0:WEND
END SUB